package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	StudentEventNew          = "study.StudentNew"
	StudentEventBeforeCreate = "study.StudentBeforeCreate"
	StudentEventBeforeUpdate = "study.StudentBeforeUpdate"
	StudentEventBeforeSave   = "study.StudentBeforeCreate study.StudentBeforeUpdate"
	StudentEventAfterCreate  = "study.StudentAfterCreate"
	StudentEventAfterUpdate  = "study.StudentAfterUpdate"
	StudentEventAfterSave    = "study.StudentAfterCreate study.StudentAfterUpdate"
	StudentEventDelete       = "study.StudentDelete"

	StudentAccessControlEvent = "study.StudentAccessControl"
)

func GetStudentConfig() *mgo.DocConfig {
	return Student_Config
}

var Student_Config *mgo.DocConfig

func init() {
	Student_Config = NewStudentConfig()
}

func NewStudentConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "study.Student",
		Fields: []string{
			"name", "grade",
		},
		RelationFields: []string{
			"grade",
		},
		RelationConfigs: map[string]*mgo.DocRelation{

			"grade": {
				Config:     GetGradeConfig,
				DocName:    "Grade",
				JoinType:   "O",
				KeyInside:  "gradeId",
				KeyOutSide: "id",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
